查看表内容 mysql 您所在的位置:网站首页 mysql 表单查询 查看表内容 mysql

查看表内容 mysql

2024-06-13 04:17| 来源: 网络整理| 查看: 265

一,说明:表名为student

1a1ed89cc5dfa32cf176aa7ce2bd049d.png

1,查询某个表里的字段

select 字段名1,字段名1 form student;

例如:查询student中的sname

select sname from student;

f432674abd6979239dc2f7c2b1151da9.png

2,查询某个表里的字段(字段下面有重复的内容),并且显示的查询结果不显示重复的

select distinct class from student;

c00597889effeb2844a0b84df1490d09.png

3,查询加条件

select * from student where sno='107';

7008ae5c9e6a3e41276dcf89ccb9452b.png

4,查询某个字段下满足某条件的(class为95031中ssex为女的)

select * from student where class in(95031) and ssex='女';

8505214a99e138a774d5c93d0457db3a.png

5,模糊查询

a,查询sname第一个字是王的(_代表一个字符串)

select * from student where sname like '王_';

2b4c5492264d865521c308b07a83d5cb.png

查询sname第二个字是冰的

select * from teacher where tname like '_冰';

43dd9ee1eeb5619e36019eed1d1d71b2.png

b,查询sname第一个字是王的(%代表任意字符串)

select * from student where sname like '王%';

bb8b4761161de086f2fc7c425691365f.png

c,查询sname含有王的(%代表任意字符串)

select * from student where snamelike '%王%';

1475c5058321bd5136421a31c7def0a0.png

where中可用的运算符有:算术运算符: +  -  *  /   %

比较运算符: >   >=   (不等于)   ==(等于,mysql扩展),!=(不等于,mysql扩展)

逻辑运算符: and(与)  or(或) not(非)

6.分页查询 limit

limit 0,2    0代表下标  2代表显示的个数

426acf9848aa650841e39b1acd67575b.png

二,说明 表名为score

9b9fa412e2077b8f14ba704b1a3597d3.png

1,查询degree是60到70的

select * from score where degree between '60' and '70';

也可以用比较运算符这样写:select * from scorewhere degree>60 and degree



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有